package biz.innovasoft.nodb.transaction;


import java.util.Date;
import java.util.List;

import org.prevayler.Prevayler;
import org.prevayler.Query;

import biz.innovasoft.nodb.impl.GenericRepository;
import biz.innovasoft.nodb.query.Tuple;
import biz.innovasoft.nodb.util.ArrayUpdateableList;

public class SelectClassesQuery implements Query {

	private Class<?>clazz;
	private Prevayler prevayler;
	
	public SelectClassesQuery (Prevayler prevayler, Class<?> clazz) {
		this.prevayler = prevayler;
		this.clazz = clazz;
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public Object query(Object system, Date time) throws Exception {
		GenericRepository repository = (GenericRepository)system;
		List<Tuple> list = repository.getAll(clazz);
		
		ArrayUpdateableList ulist = new ArrayUpdateableList(prevayler, list);
		return ulist;
	}

}
